#include <iostream>
#include <array>
#include <vector>
#include <span>
#include "fmt/format.h"
using namespace std;


int main() {

    const auto display{
        [](const auto& items) {
            for (const auto& item : items) {
                cout << fmt::format("{} ", item);
            }
            cout << "\n";
        }
    };

    const auto displayArray{
        [](const int items[],size_t size) {
            for (size_t i{0};i < size;++i) {
                cout << fmt::format("{} ", items[i]);
            }
            cout << "\n";
        }
    };

    const auto displaySpan{
        [](std::span<const int> items) {
            for (const auto& item : items) {
                cout << fmt::format("{} ", item);
            }
            cout << "\n";
        }
    };

    // auto res = sizeof(display);
    // auto res1 = sizeof display;

    int values1[]{ 10,20,30 ,40,50,60 };
    std::array values2{ 6,8,10,12 };
    std::vector values3{ 11,22,33,44,55 };

    cout << "values1 built-in arry:\n";
    displayArray(values1, 6);

    cout << "values1 built-in arry via displayspan :\n";
    displaySpan(values1);

    cout << "values2 std::arry:\n";
    displaySpan(values2);

    cout << "values3 vector:\n";
    displaySpan(values3);

    std::span mySpan{ values1 };
    cout << fmt::format("mySpan's first element is {}\n", mySpan.front());
    cout << fmt::format("mySpan's last element is {}\n", mySpan.back());

    displaySpan(mySpan.first(3));
    displaySpan(mySpan.last(3));
    displaySpan(mySpan.subspan(1, 3));

    cout << mySpan[8];


    return 0;
}